import {Component, Input, OnInit} from '@angular/core';

@Component({
    selector: 'app-pager',
    templateUrl: './pager.component.html',
    styleUrls: ['./pager.component.css']
})
export class PagerComponent implements OnInit {
    @Input()
    pageNo: number;

    @Input()
    pageSize: number;

    @Input()
    classes: string;

    @Input()
    id: string;

    private _total = 0;

    /**
     * 总共可分多少页
     * @type {number}
     */
    totalPage: number;

    constructor() {
    }

    get total(): number {
        return this._total;
    }

    @Input()
    set total(value: number) {
        this._total = value;
        this.totalPage = Math.trunc((this._total - 1 + this.pageSize) / this.pageSize);
    }

    ngOnInit() {
    }
}
